<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common/metaHead.jsp"%>
<div class="column half fl">
<div class="box"><h2 class="box-header">码表管理 </h2>
<div class="box-content">
		<form:form action="${mvcpath}/save.do" modelAttribute="entity" method="post" id="typeForm">
		<form:hidden path="id"/>
		 
	 	 <label class="form-label" >码表类型</label> 
	 <form:input path="type"  cssClass="form-field half" />
	 
		 <label class="form-label" >中文名称</label> 
		<form:input path="cnName"   cssClass="form-field half"/>
		
		 <label class="form-label" >值类型</label> 
		 <select class="form-field half" name="valueType">
		 <option value="S" <c:if test="${entity.valueType eq 'S'}">selected</c:if>>字符</option>
		  <option value="I" <c:if test="${entity.valueType eq 'I'}">selected</c:if>>整数</option>
		   <option value="D" <c:if test="${entity.valueType eq 'D'}">selected</c:if>>日期</option>
		    <option value="L" <c:if test="${entity.valueType eq 'L'}">selected</c:if>>长整形</option>
		     <option value="N" <c:if test="${entity.valueType eq 'N'}">selected</c:if>>浮点</option>
		      <option value="B" <c:if test="${entity.valueType eq 'B'}">selected</c:if>>真假</option>
		      <option value="C" <c:if test="${entity.valueType eq 'C'}">selected</c:if>>集合</option>
		 </select>
         
		<div class="clear"></div>
		<br/>
		<hr/>
		 
		<div style="clear:both;height:36px;" >
		<ul style="float:right;">
			 <li style="float:left;"><input id="cancel" class="button themed" type="button" value="取 消" name="cancel" /></li>
			 <li style="float:left;"><input id="validate" class="button themed" type="button" value="保 存" name="submit" onclick="submitCodeType()"/></li>
 		</ul>
		</div>
</form:form>
</div></div></div>

<script type="text/javascript">
 
 function submitCodeType()
 {
	 $form=$("#typeForm");
	 alert($form.serializeArray());
	 $.ajax({
		    type:'POST',
			url:$form.attr("action"),
			data:$form.serializeArray(),
			cache: false,
			dataType:"text",
			success:function(data, textStatus){
				$("#codeContent").html(data);
			}
		 
		});
 }
 function addCode(typeId,itemId)
 {
	 var finalType;
	 var ctypeId=$("#stypeId").val();
	 if(typeId==''&&ctypeId=='')
		 return ;
	 if(typeId!='')
		 {
		 finalType=typeId;
		 }
	 else
		 {
		 finalType=ctypeId;
		 }
	 var surl='${mvcpath}/codeinput.do?codeTypeId='+finalType;
  if(itemId)
	{
	  surl=surl+'&id='+itemId;
	}
	
	  $.ajax({
		  type:'POST',
		 	url:surl,
		 	cache: false,
		 	success:function(data, textStatus){
		 	$("#codeContent").html(data);
		 }
		 });
	 
 }
 
 function saveCode()
 {
var	 $form=$("#codeForm");
	 $.ajax({
		 type:'POST',
			url:$form.attr("action"),
			data:$form.serializeArray(),
			cache: false,
			success:function(data, textStatus){
				$("#codeContent").html(data);
			}
		 
		});
	 
 }
 
 function deleteCode(typeId,itemId)
 {
	 $.ajax({
		 type:'POST',
		 	url:'${mvcpath}/codeinput.do?codeTypeId='+typeId+'&id='+id,
		 	cache: false,
		 	success:function(data, textStatus){
		 	$("#codeContent").html(data);
		 }
		 });
 }
 
 function cacelSave(typeId)
 {
	 $.ajax({
		 type:'POST',
		 	url:'${mvcpath}/codelist.do?typeId='+typeId,
		 	cache: false,
		 	success:function(data, textStatus){
		 	$("#codeContent").html(data);
		 }
		 });
 }
</script>
    <div class="column half fr">
 	 <div class="box">
 	 <h2 class="box-header-add">
			<a class="button grey" href="#"	onclick="addCode('${entity.id}')"><span class="icon_text"></span>新增</a>
		</h2>
            <h2 class="box-header">码表维护</h2>
            <div class="box-content" id="codeContent">
            <c:if test="${listCode ne null}">
            		<table class="tablebox">
					<thead class="table-header">
					<tr id="dataHeadTr">
						<th class="tc">序号</th>
						<th id="code" ><span></span>代码</th>
						<th id="stringValue"><span></span>字符值</th>
						<th id="enable" ><span></span>是否可用</th>
						<th class="tc">操作</th>
					</tr>
				</thead>
			<tbody class="openable-tbody">
			<c:forEach var="item" items="${listCode}" varStatus="status">
			<tr class="<c:choose><c:when test="${status.count%2==0 }">odd</c:when><c:otherwise>even</c:otherwise></c:choose>">
			<td class="first tc">${status.count}</td>
			<td>${item.code}</td>
			<td>${item.stringValue}</td>
			<td>	<c:if test="${!item.enable}">
			<span class="bullet bullet-red"></span>
			</c:if>
			<c:if test="${item.enable}">
			<span class="bullet bullet-green"></span>
			</c:if>
			</td>
			<td class="tc">		
			<a class="button white" href="#" onclick="deleteCode('${entity.id}','${item.id}');"><span class="icon_single cancel"></span></a>
			<a class="button white" href="#" onclick="addCode('${entity.id}','${item.id}');"><span class="icon_single edit"></span></a>
			 </td>
			</tr>
			</c:forEach>
		</tbody>
     </table>
            
            </c:if>
            
            </div>
          </div>
 </div>
 <%@ include file="/common/foot.jsp"%>
 
  